<?php

class supplier_info{
public function index(){
$location_id = intval($GLOBALS['request']['supplier_id']);
$sql= 'SELECT id,name,address,tel,route,preview,deal_cate_id,xpoint,ypoint,avg_point,avg_price as price_type,open_time,dp_count as commend_count  FROM '.DB_PREFIX."supplier_location  WHERE id='{$location_id}' and deal_type=0  ";
$result= $GLOBALS['db']->query($sql);
$list= $GLOBALS['db']->fetch_array($result);
$list['point']=score2Half($list['avg_point']);
$list['image']=get_abs_img_root(get_spec_image($list['preview'],640,240,1));
$list['avg_price_format'] = '￥'.$GLOBALS['lang']['AVG_PRICE_'.$list['price_type']];
$list['cursine']=  $GLOBALS['db']->getOne('SELECT name FROM '.DB_PREFIX."deal_cate WHERE id='{$list['deal_cate_id']}' ");
$impression=  $GLOBALS['db']->getAll('SELECT name FROM '.DB_PREFIX."location_impression WHERE sid='{$list['id']}' ");
$list['impression']=array();
foreach($impression as $ke=>$va)
{
array_push($list['impression'],$va['name']);
}
$list ['specialty_dish']=  $GLOBALS['db']->getAll('SELECT name,price,is_special FROM '.DB_PREFIX."supplier_location_menu WHERE supplier_location_id='{$location_id}' ");
$list['group_point'] = $GLOBALS['db']->getAll('select id,name from '.DB_PREFIX.'point_group as pg left join '.DB_PREFIX.'point_group_link as pgl on pg.id = pgl.point_group_id  where pgl.category_id = '.$list['deal_cate_id'].' order by sort asc');
foreach($list['group_point'] as $kk=>$vv)
{
$list['group_point'][$kk]['avg_point'] =  round(floatval($GLOBALS['db']->getOne('select avg_point from '.DB_PREFIX.'supplier_location_point_result where supplier_location_id = '.$list['id'].' and group_id = '.$vv['id'])),1);
}
$list ['commend']=  $GLOBALS['db']->getAll('SELECT id,title,content,create_time,user_id,point FROM '.DB_PREFIX."supplier_location_dp WHERE supplier_location_id='{$list['id']}' ");
foreach($list ['specialty_dish'] as $sk=>$sv)
{
$list ['specialty_dish'][$sk]['price']= round($sv['price'],1);
}
foreach($list['commend'] as $keyy=>$valuee)
{
$list['commend'][$keyy]['create_time']=date('Y-m-d  H:m:s',$valuee['create_time']);
$list['commend'][$keyy]['user_name']=$GLOBALS['db']->getOne('select user_name from '.DB_PREFIX.'user where id = '.$valuee['user_id'].'  ');
$list['commend'][$keyy]['user_avatar']=get_abs_img_root(get_muser_avatar($list['commend']['user_id'],'small'));
$list['commend'][$keyy]['group_point'] = $GLOBALS['db']->getAll('select pg.name,pg.id from '.DB_PREFIX.'point_group as pg left join '.DB_PREFIX.'point_group_link as pgl on pg.id = pgl.point_group_id where pgl.category_id = '.intval($list['deal_cate_id']).' order by pg.sort asc');
foreach( $list['commend'][$keyy]['group_point'] as $gk=>$gv)
{
$list['commend'][$keyy]['group_point'][$gk]['point']=round(floatval($GLOBALS['db']->getOne('select point from '.DB_PREFIX.'supplier_location_dp_point_result where supplier_location_id = '.$list['id'].' and dp_id='.$valuee['id'].' and group_id = '.$gv['id'])),1);
}
}
unset($list['preview'],$list['avg_point'],$list['deal_cate_id'],$list['price_type']);
$root=array();
$root['item']=$list;
output($root);
}
}
?>